<template>
  <div>
    <DatePicker @on-change="dateChange" type="daterange" :options="dateOptions" placement="bottom-start" placeholder="日期"/>
  </div>
</template>

<script>
export default {
  name: 'my-date-picker',
  data () {
    return {
      dateOptions: {
        shortcuts: [
          {
            text: '两天内',
            value () {
              const end = new Date()
              const start = new Date()
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 2)
              return [start, end]
            }
          },
          {
            text: '一周内',
            value () {
              const end = new Date()
              const start = new Date()
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
              return [start, end]
            }
          },
          {
            text: '一个月内',
            value () {
              const end = new Date()
              const start = new Date()
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
              return [start, end]
            }
          }
        ]
      }
    }
  },
  methods: {
    dateChange (date) {
      this.$emit('dateChange', date)
    }
  },
  created () {}
}
</script>

<style scoped>

</style>
